package edu.colorado.cs.correll.cudroplet.shaperecognition;

import processing.core.PApplet;

import com.vividsolutions.jts.algorithm.Angle;
import com.vividsolutions.jts.geom.Coordinate;

public class Circumcircle {
	float diameter;
	Robot a;
	Robot b;
	
	public Circumcircle(float diameter, Robot a, Robot b) {
		this.diameter = diameter;
		this.a = a;
		this.b = b;
	}
	
	public Coordinate getCenter() {
		Coordinate coordA = a.getCoordinate();
		Coordinate coordB = b.getCoordinate();
		double angleAB = Angle.angle(coordA, coordB);
		double d = coordA.distance(coordB);
		double theta = PApplet.acos((float) ((d/2)/(diameter/2)));
		double angle = angleAB + theta;
		return new Coordinate(a.x + diameter/2 * PApplet.cos((float) angle), 
				a.y + diameter/2 * PApplet.sin((float) angle));
	}
}
